﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GenericLibrariesToolKit;
using Utils;

namespace Model
{
    /// <summary>
    /// 事件实体
    /// </summary>
    public class Event
    {
        /*事件ID*/
        public string EventId { get; set; }
        /*事件发表者ID*/
        public string EventPosterId { get; set; }
        /*事件标题*/
        public string EventTitle { get; set; }
        /*关键字*/
        public string EventKey { get; set; }
        /*事件描述*/
        public string EventDescription { get; set; }
        /*日期*/
        private string eventDate = DateTimeUtil.GetDateTime();
        public string EventDate
        {
            get { return eventDate; }
            set { eventDate = value; }
        }
        /*事件地点*/
        public string EventAddress { get; set; }
        /*点击量*/
        public long EventClickAmount { get; set; }

        /// <summary>
        /// 应用程序启动时，实体管理器将会调用此方法进行初始化。
        /// </summary>
        public void Intialization()
        {
            //声明一个实体实体对象
            Entity entity = new Entity();

            //指定该实体对应数据库中的表名
            entity.TableName = "T_EVENT";
            //指定该实体的标识符
            entity.EntityId = "EventId";
            //指定主键生成策略
            entity.Generator = GenericLibrariesToolKit.Enumeration.PKGenerationStrategy.GUID;
            ///实体关系映射字典
            ///key:实体属性名称，value:对应的数据库中表的字段名
            Dictionary<string, string> dictionary = new Dictionary<string, string>();

            dictionary.Add("EventId", "EVENT_ID");
            dictionary.Add("EventPosterId", "EVENT_POSTER_ID");
            dictionary.Add("EventTitle", "EVENT_TITLE");
            dictionary.Add("EventKey", "EVENT_KEY");
            dictionary.Add("EventDescription", "EVENT_DESCRIPTION");
            dictionary.Add("EventDate", "EVENT_DATE");
            dictionary.Add("EventAddress", "EVENT_ADDRESS");
            dictionary.Add("EventClickAmount", "EVENT_CLICK_AMOUNT");

            //赋值
            entity.ORMDictionary = dictionary;

            //将实体加入实体管理器，
            EntityManager.GetInsatnce().AddEntity("Model.Event", entity);
        }
    }
}
